package team.nmsg.ge.system.dao;

import java.util.List;
import java.util.Set;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import team.nmsg.ge.system.bean.SysRole;
import team.nmsg.ge.system.bean.SysUser;

@Repository
public interface ISysUserRepository extends JpaRepository<SysUser, Integer>{

	/**
	 * 通过用户名和密码查询用户
	 * @param username
	 * @param password
	 * @return
	 */
	public SysUser findByUsernameAndPassword(String username, String password);
	
	/**
	 * 通过用户名查询用户Id
	 * @param username
	 * @return
	 */
	@Query(value="select u.userId from SysUser u where u.username=:name")
	public String findUserIdByUsername(@Param("name")String username);
	
	public List<SysUser> findByRolesIn(Set<SysRole> roles);
}
